namespace Super
{
	/// <summary>
	/// 可以保存当前信息的单例
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public class SaveSingle<T> where T : SaveSingle<T>, new()
	{
		private static T ins;

		public static T Ins
		{
			get
			{
				if (ins == null)
				{
					ins = AssetUtil.LoadByAsset<T>(string.Format(FWConfig.singleDataPath, typeof(T).Name));
				}
				if (ins == null)
				{
					ins = new T();
				}
				return ins;
			}
		}

		/// <summary>
		/// 保存单例信息
		/// </summary>
		public static void SaveData()
		{
			AssetUtil.SaveToAsset(string.Format(FWConfig.singleDataPath, typeof(T).Name), ins);
		}
	}
}
